<template>
	<basic-container>
		<el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="所有订单" name="-10"></el-tab-pane>
			<el-tab-pane label="待付款" name="10"></el-tab-pane>
			<el-tab-pane label="待分享" name="17"></el-tab-pane>
			<el-tab-pane label="待发货" name="27"></el-tab-pane>
			<el-tab-pane label="待收货" name="30"></el-tab-pane>
			<el-tab-pane label="已收货" name="40"></el-tab-pane>
			<el-tab-pane label="已完成" name="50"></el-tab-pane>
			<el-tab-pane label="已取消" name="0"></el-tab-pane>
			<el-tab-pane label="退款审核" name="-1"></el-tab-pane>
			<el-tab-pane label="退款完成" name="-2"></el-tab-pane>
			<el-tab-pane label="产生售后订单" name="-3"></el-tab-pane>
		</el-tabs>
		<avue-crud
			:option="option"
			:data="data"
			ref="crud1"
			:table-loading="loading"
			:permission="permissionList"
			:page="page"
			:cell-style="cellStyle1"
			@refresh-change="refreshChange"
			@search-change="searchChange"
			@search-reset="searchReset"
			@current-change="currentChange"
			@size-change="sizeChange"
			@selection-change="selectionChange"
			@on-load="onLoad"
		>
			<template slot-scope="{ row }" slot="totalPrice">
				<div>
					<p>{{ row.totalPrice }}</p>
				</div>
			</template>
			<template slot-scope="{ row }" slot="user">
				<span @click="callUser(row.userId)" style="color: #ee0a24;cursor: pointer">
					{{ row.userName }}
					<i style="color: #ee0a24;width: 20px;height: 20px;" class="el-icon-message"></i>
				</span>
			</template>
			<template slot-scope="scope" slot="menu">
				<el-button type="text" size="small" @click="seeDetails(scope.row.id,scope.row.storeWillCallId)">查看详情</el-button>
				<el-button  type="text" size="small" @click="viewOrderGoods(scope.row.id)" >
					查看订单商品
				</el-button>
				<el-button type="text" v-if="scope.row.orderStatus == 20" size="small" @click="checkGoods(scope.row.id, scope.row)">审核</el-button>
				<el-button type="text" v-if="scope.row.orderStatus == 20 || scope.row.orderStatus == 27" size="small" @click="refundGoods(scope.row.id)">退款</el-button>
				<el-button type="text" v-if="scope.row.orderStatus == 20" size="small" @click="editAddress(scope.row.id)">修改地址</el-button>
				<el-button type="text" v-if="scope.row.orderStatus == 10" size="small" @click="cancelOrderDetail(scope.row.id, scope.row.orderId)">取消订单</el-button>
				<el-button type="text" v-if="scope.row.orderStatus == 10" size="small" @click="changeOrderPrice(scope.row)">修改价格</el-button>
				<el-button type="text" v-if="scope.row.orderStatus == -1" size="small" @click="refundGoodsCheck(scope.row.id, scope.row.oRefundApplyReason)">退款审核</el-button>
			</template>
			<!-- 自定义添加搜索条件  按日期搜索  -->
			<template slot="search">
				<el-col :md="24" :xs="12" style="width: 50%;float: left;height:50px">
					<el-form-item label="下单时间" style="width: 50%;display: inline-block;">
						<el-date-picker size="mini" placeholder="开始时间" @change="getBeginTime" value-format="yyyy-MM-dd HH:mm:ss" v-model="addTimeBegin" type="datetime"></el-date-picker>
					</el-form-item>
					<el-form-item label="至" style="width: 50%;display: inline-block;">
						<el-date-picker size="mini" placeholder="结束日期" @change="getEndTime" value-format="yyyy-MM-dd HH:mm:ss" v-model="addTimeEnd" type="datetime"></el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :md="24" :xs="12" style="display: flex;width:50%;float:left">
				    <el-form-item label="业务发生区域" label-width="120px" style="display: inline-block;">
				        <el-select size="small" v-model="rareaId" placeholder="区域"
				                   @change="changeAreaForRongChuang(rareaId,3)">
				            <el-option v-for="item in rareas" :key="item.id" :label="item.name"
				                       :value="item.id">
				            </el-option>
				        </el-select>
				    </el-form-item>
				    <el-form-item 　label-width="10px" style="display: inline-block;">
				        <el-select size="small" v-model="rcityId" placeholder="城市"
				                   @change="changeAreaForRongChuang(rcityId,4)">
				            <el-option v-for="item in rcitys" :key="item.id" :label="item.name"
				                       :value="item.id">
				            </el-option>
				        </el-select>
				    </el-form-item>
				    <el-form-item 　label-width="10px" style="display: inline-block;">
				        <el-select size="small" v-model="projectId" placeholder="项目"
				                   @change="changeAreaForRongChuang(projectId,5)">
				            <el-option v-for="item in projects" :key="item.id" :label="item.name"
				                       :value="item.id">
				            </el-option>
				        </el-select>
				    </el-form-item>
				</el-col>
			</template>
			<template slot="searchMenu">
<!--				<el-button type="primary" size="mini" @click="outExcel">导出订单</el-button>-->
				<el-button type="primary" size="mini" @click="outLittleExcel">部分导出</el-button>
				<el-button type="primary" size="mini" @click="outOrderGoodsExcel">导出订单</el-button>
			</template>
		</avue-crud>
		<el-col class="btnRow" :span="8">
			<span class="allMoney">订单实付款：{{allMoney}}</span>
		</el-col>
		<el-drawer  :with-header="false" :before-close="closeOrderGoods" :visible.sync="dialogOrderGoodsVisible" size="88%">
			<div class="demo-drawer__header">
				<div class="drawerHeader">
					<strong>订单商品详情</strong>
				</div>
			</div>
			<avue-crud ref="crudOrderGood" :option="option1" v-if="orderFormGoodsResults.length>0"  :data="orderFormGoodsResults" @on-load="onload(row)" :row-style="rowStyle">
				<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
					<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
				</template>
				<template slot-scope="{ row }" slot="goodsName">
					<div>
						{{ row.goodsName }}
						<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
					</div>
				</template>
			</avue-crud>
			<div v-else class="loading_icon"><i class="el-icon-loading"></i></div>
		</el-drawer>
		<el-dialog title="取消订单" size="60%" center :visible.sync="dialogCancelForm">
			<el-form :model="form" :rules="cancelRules" v-if="dialogType == 0">
				<el-form-item :label-width="formLabelWidth"><span>您确定要取消下面的订单吗?</span></el-form-item>
				<el-form-item label="订单号:" :label-width="formLabelWidth">
					<span>{{ orderIdSn }}</span>
				</el-form-item>
				<el-form-item label="取消原因:" :label-width="formLabelWidth" prop="cancelReason">
					<el-radio-group v-model="cancelReason">
						<div style="padding: 0.2rem;"><el-radio :label="3">买家要求取消</el-radio></div>
						<div style="padding: 0.2rem;"><el-radio :label="6">商品缺货</el-radio></div>
						<div style="padding: 0.2rem;"><el-radio :label="9">其他原因</el-radio></div>
					</el-radio-group>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer" center v-if="dialogType == 0"><el-button type="primary" @click="cancelOrderForm">确 定</el-button></div>
		</el-dialog>
		<el-drawer :title="title" size="60%" center :visible.sync="dialogFormVisible" width="50%" :with-header="false">
			<div style="padding-top: 50px;">
				<!-- 修改地址 退款审核 -->
				<avue-form ref="form" v-model="obj" :option="optionChange" @submit="submit" v-if="dialogType == 1"></avue-form>
				<!-- 修改价格 -->
				<avue-form ref="formPrice" v-model="changePriceObj" :option="optionChangePrice" @submit="submitChangePrice" v-if="dialogType == 2">
					<template slot-scope="scope" slot="goodsMainPhotoUrl">
						<img :src="changePriceObj.goodsMainPhotoUrl" style="width:100px;height:100px;" />
					</template>
					<template slot-scope="scope" slot="lastTotalAmount">
						<p style="color:#89CA26 ;">
							{{ Number(changePriceObj.totalPrice) }}-
							<span>{{ Number(changePriceObj.couponAmountStore) }}</span>
							-
							<span>
								{{ Number(changePriceObj.couponAmountPlatform) }}-
								<span>{{ Number(changePriceObj.fullCutAmount) }}</span>
								-
								<span>{{ Number(changePriceObj.fullDiscountAmount) }}</span>
								<!-- - -->
								<span v-if="Number(changePriceObj.adjustmentPrice) > 0 || Number(changePriceObj.adjustmentPrice) == 0">+</span>
								<span>{{ Number(changePriceObj.adjustmentPrice) }}</span>
								+
								<span>{{ Number(changePriceObj.actualShipmentAmount) }}</span>
							</span>
							=
							<span>
								<span style="color: #F45A12;">{{ Number(lastAmount) }}</span>
								元
							</span>
						</p>
					</template>
					<template slot-scope="scope" slot="reason">
						<div class="reason">
							<p>买家实付=(当时商品价格 * 数量) - 店铺优惠-平台优惠-满减活动优惠-满折活动优惠+涨价或降价+运费</p>
							<p>邮费为0时货到付款服务费由卖家承担</p>
						</div>
					</template>
				</avue-form>
			</div>
		</el-drawer>
		<!--	详情	-->
		<el-drawer title="订单详情" :visible.sync="dialogDeatilVisible" size="88%" :with-header="true">
			<avue-form :option="optionDetail" v-model="form1">
				<template slot="group1Header">
					<h4>订单信息</h4>
				</template>
				<template slot="group2Header">
					<h4>卖家信息</h4>
				</template>
				<template slot="group3Header">
					<h4>配货单信息</h4>
				</template>
				<template slot="group4Header">
					<h4>优惠信息</h4>
				</template>
				<template slot="group5Header">
					<h4>收货地址</h4>
				</template>
				<template slot="group6Header">
					<h4>支付信息</h4>
				</template>
				<template slot="group7Header">
					<h4>门店自提信息</h4>
				</template>
				<template slot="group9Header">
					<h4>售后单信息</h4>
				</template>
				<template slot="group8Header">
					<h4>操作历史</h4>
				</template>
				<template slot-scope="scope" slot="menuForm">
					<el-button @click="closeDetailDialog">关闭</el-button>
				</template>
				<template slot-scope="scope" slot="coupon">
					<div>
						<p>
							运费：
							<span style="padding: 0 0.3rem;">{{ form1.actualShipmentAmount }}</span>
						</p>
						<p>
							店铺优惠：
							<span style="padding: 0 0.3rem;">{{ form1.couponAmountStore }}</span>
						</p>
						<p>
							平台优惠：
							<span style="padding: 0 0.3rem;">{{ form1.couponAmountPlatform }}</span>
						</p>
						<!-- <p v-if="form1.fullCutAmount > 0">满减优惠：<span style="padding: 0 0.3rem;">{{form1.fullCutAmount}}</span></p>
						<p v-if="form1.fullDiscountAmount > 0">满折优惠：<span style="padding: 0 0.3rem;">{{form1.fullDiscountAmount}}</span></p> -->
						<p>
							订单总价：
							<span style="padding: 0 0.3rem;">{{ form1.totalPrice }}</span>
						</p>
						<p>
							总付款：
							<span style="padding: 0 0.3rem;">{{ form1.lastAmount }}</span>
						</p>
						<p v-if="form1.storeReward != null">
							商家奖励团长金额：
							<span style="padding: 0 0.3rem;">{{ form1.storeReward }}</span>
						</p>
						<p v-if="form1.platformReward != null">
							平台奖励团长金额：
							<span style="padding: 0 0.3rem;">{{ form1.platformReward }}</span>
						</p>
					</div>
				</template>
				<template slot-scope="scope" slot="goodsDetails">
					<avue-crud :data="form1.goodsDetail" :option="option1">
						<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
							<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
						</template>
						<template slot-scope="{ row }" slot="goodsName">
							<div>
								{{ row.goodsName }}
								<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
							</div>
						</template>
					</avue-crud>
				</template>
				<template slot-scope="scope" slot="invoiceType">
					<div>
						<p v-if="form1.invoiceType == 0">个人</p>
						<p v-if="form1.invoiceType == 1">单位</p>
						<p v-if="form1.invoiceType == 2">不开发票</p>
					</div>
				</template>
				<template slot-scope="scope" slot="invoiceTitle">
					<p>{{ form1.invoiceTitle }}</p>
				</template>
				<template slot-scope="scope" slot="invoiceNum">
					<p>{{ form1.invoiceTaxNum }}</p>
				</template>
				<template slot-scope="scope" slot="invoiceEmail">
					<p>{{ form1.invoiceEmail }}</p>
				</template>
				<template slot-scope="scope" slot="invoiceUploadResultMsg">
					<p>{{ form1.invoiceUploadResultMsg }}</p>
				</template>
				<template slot-scope="scope" slot="history">
					<div style="padding: 0.2rem;">
						<p v-for="item of form1.historyLog" :key="item.id">
							<span style="padding: 0 0.1rem;" v-if="item.stateInfo">{{ item.stateInfo }}：</span>
							<span style="color: #ff9900;padding: 0 0.2rem;">{{ item.userName }}</span>
							<span style="padding: 0 0.1rem;" v-if="item.stateInfo == '订单取消'">
								于
								<span style="padding: 0 0.1rem;">{{ item.addTime }}</span>
								取消订单
								<p style="padding: 0 0.1rem;">取消原因：{{ item.logInfo }}</p>
							</span>
							<span style="padding: 0 0.1rem;" v-else>
								于
								<span style="padding: 0 0.1rem;">{{ item.addTime }}</span>
								{{ item.logInfo }}
							</span>
						</p>
					</div>
				</template>
				<template slot-scope="scope" slot="distributionSn1">
					<div>
						<div class="distribution" v-if="form1.orderDistributionList.length == 0">暂无配货单信息</div>
						<div class="distribution" v-for="item of form1.orderDistributionList" :key="item.id">
							<el-form :model="item">
								<el-form-item>
									<span style="padding: 0.1rem 0.5rem">配货单号：{{ item.distributionSn }}</span>
									<span style="padding: 0.1rem 0.5rem">生成时间：{{ item.addTime }}</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 0">配货单状态：未发货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 1">配货单状态：已发货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 2">配货单状态：已完成</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 3">配货单状态：已退款</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == 4">配货单状态：已收货</span>
									<span style="padding: 0.1rem 0.5rem" v-if="item.status == -1">配货单状态：退款审核</span>
								</el-form-item>
								<el-form-item v-if="item.orderFormGoodsResultList.length > 0">
									<avue-crud ref="crud2" :option="option1" :data="item.orderFormGoodsResultList">
										<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
											<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
										</template>
										<template slot-scope="{ row }" slot="goodsName">
											<div>
												{{ row.goodsName }}
												<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
											</div>
										</template>
									</avue-crud>
								</el-form-item>
								<el-form-item v-else>
									<avue-crud ref="crud2" :option="option1" :data="form1.goodsDetail">
										<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
											<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
										</template>
										<template slot-scope="{ row }" slot="goodsName">
											<div>
												{{ row.goodsName }}
												<span style="color: red;" v-if="row.acType == 8">[赠品]</span>
											</div>
										</template>
									</avue-crud>
								</el-form-item>
								<el-form-item v-if="form1.expressType == 1">
									<p v-if="item.ecName">物流公司：{{ item.ecName }}</p>
									<p v-if="item.shipCode">物流单号：{{ item.shipCode }}</p>
									<p v-if="item.shipCode">操作说明：{{ item.distributionDesc }}</p>
									<el-steps v-if="item.expressInfoBean" direction="vertical" :active="item.expressInfoBean.data.length">
										<el-step
											v-for="obj of item.expressInfoBean.data"
											icon="el-icon-success"
											:key="obj.index"
											style="padding: 0.2rem;"
											:description="obj.time + obj.context"
										></el-step>
									</el-steps>
								</el-form-item>
							</el-form>
						</div>
					</div>
				</template>

				<template slot-scope="scope" slot="serviceSn">
					<div>
						<div class="distribution" v-if="form1.orderAfterSaleServiceResultList.length == 0">暂无售后单信息</div>
						<div class="distribution" v-for="item of form1.orderAfterSaleServiceResultList" :key="item.id">
							<el-form :model="item">
								<el-form-item>
									<span style="padding: 0.1rem 0.5rem">
										售后单号：
										<span @click="goAfterSaleServiceDetail(item.id)" style="color: #ff9900;padding: 0 0.2rem;cursor:pointer;">{{ item.serviceSn }}</span>
									</span>
								</el-form-item>
							</el-form>
						</div>
					</div>
				</template>
			</avue-form>
		</el-drawer>
	</basic-container>
</template>

<script>
var VAILD = [
	{
		label: '通过',
		value: 'true'
	},
	{
		label: '拒绝',
		value: 'false'
	}
];
import {
	getList,
	approveOrder,
	cancelOrder,
	refundOrder,
	refundSuccess,
	getOrderAddress,
	modifyOrderAddress,
	getOrderAmount,
	updatePrice,
	getDetail,
	getOrderFormGoods,
	getCallbackIdByPayFormId
} from '@/api/order/seller/orderForm';
import {
		getOrganizationListByLevel
} from "@/api/admin/area";
import { getStoreWillCallId} from '@/api/order/orderForm';
import { mapGetters } from 'vuex';
import { getToken } from '@/util/store';
var baseUrl = '/base/area/getAreaListByLevel';
import { testPhone } from '@/util/util';
var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
var orderStatusEnum = []
Dict.orderStatusEnum.forEach(item=>{
	if(item.label!='待审核' && item.label!='待评价'){
		orderStatusEnum.push(item)
	}
})
orderStatusEnum.push({value:-3,label:'产生售后订单'});
export default {
	data() {
		return {
			areaId: null,
			cityId: null,
			rareaId: null,
			rcityId: null,
			projectId: null,
			// area: '',
			// city: '',
			// project: '',
			areas: [],
			citys: [],
			projects: [],
			rareas: [],
			rcitys: [],
			idList: [],
			allMoney:0,
			Fntimer: null,
			actualShipmentAmount: 0.0, //运费记录 是否先改运费
			adjustmentPrice: 0.0, //降价记录 是否先改运费
			lastAmount: 0.0, //计算后的价格
			arr: [],
			formLabelWidth: '200px',
			title: '取消订单',
			dialogType: 1, //0 取消订单
			dialogFormVisible: false,
			dialogCancelForm: false,
			dialogDeatilVisible: false,
			activeName: '-10',
			orderId: '',
			orderIdSn: '',
			cancelReason: '',
			addTimeBegin: '',
			addTimeEnd: '',
			form: {},
			cancelRules: {
				cancelReason: [{ required: true, message: '请选择原因', trigger: 'blur' }]
			},
			form1: {},
			obj: {},
			data1: {},
			changePriceObj: {},
			query: {},
			loading: true,
			rolesTree: [],
			rolesKeys: [],
			box: false,
			page: {
				pageSize: 10,
				currentPage: 1,
				total: 0
			},

			//查看详情
			optionDetail: {
				size: 'mini',
				submitBtn: false,
				emptyBtn: false,
				group: [
					{
						prop: 'group1',
						column: [
							{
								label: '订单编号',
								prop: 'orderId',
								type: 'text',
								span:8,
								disabled: true,
							},
							{
								label: '下单时间',
								prop: 'oPayTime',
								span:8,
								disabled: true,
							},
							{
								label: '支付时间',
								prop: 'oPayTime',
								span:8,
								disabled: true,
							},
							{
								label: '支付方式',
								prop: 'payWay',
								type: 'select',
								span:8,
								dicData: Dict.payWayEnum,
								disabled: true
							},
							{
								label: '配送方式',
								prop: 'expressType',
								type: 'select',
								span:8,
								disabled: true,
								dicData: Dict.expressTypeEnum,
							},
							{
								label: '业务发生区域',
								labelWidth: 100,
								span:8,
								prop: 'regionalOrganizationStr',
								disabled: true,
							},
							{
								label: '业务发生单元',
								labelWidth: 100,
								span:8,
								prop: 'businessUnitOrganizationStr',
								disabled: true,
							},
							{
								label: '业务发生项目',
								labelWidth: 100,
								span:8,
								prop: 'itemOrganizationStr',
								disabled: true,
							}
						]
					},
					{
						//卖家信息
						prop: 'group2',
						column: [
							{
								label: '店铺名称',
								prop: 'storeName',
								disabled: true,
								span:8,
							},
							{
								label: '店铺账号ID',
								prop: 'tripartiteStoreId',
								disabled: true,
								span:8,
							},
							{
								label: '店铺类型',
								prop: 'storeTypeName',
								disabled: true,
								span:8,
							}
						]
					},
					{
						//配货单信息
						prop: 'group3',
						column: [
							{
								prop: 'distributionSn1',
								formslot: true,
								span: 24
							}
						]
					},
					{
						//优惠信息
						prop: 'group4',
						column: [
							{
								prop: 'coupon',
								formslot: true
							}
						]
					},
					{
						//收货地址
						prop: 'group5',
						display: true,
						column: [
							{
								label: '收货人',
								prop: 'trueName',
								disabled: true,
								span:8,
							},
							{
								label: '电话号码',
								prop: 'mobile',
								disabled: true,
								span:8,
							},
							{
								label: '买家留言',
								prop: 'buyerMsg',
								disabled: true,
								span:8,
							},
							{
								label: '收货地址',
								prop: 'address',
								disabled: true,
								span:8,
							},
							{
								label: '详细地址',
								prop: 'areaInfo',
								disabled: true,
								span:8,
							},
							{
								label: '发票类型',
								prop: 'invoiceType',
								formslot: true,
								span:8,
							},
							{
								label: '发票抬头',
								prop: 'invoiceTitle',
								display: true,
								formslot: true,
								span:8,
							},
							{
								label: '纳税人识别号',
								prop: 'invoiceNum',
								labelWidth: 120,
								display: true,
								formslot: true,
								span:8,
							},
							{
								label: '收件邮箱',
								prop: 'invoiceEmail',
								display: true,
								formslot: true,
								span:8,
							},
							{
								label: '开票结果',
								prop: 'invoiceUploadResultMsg',
								display: true,
								formslot: true,
								span:8,
							}
						]
					},
					{
						//收货地址
						prop: 'group6',
						column: [
							{
								label: '支付单号',
								prop: 'pfCode',
								disabled: true,
								span:8,
							},
							{
								label: '三方订单号',
								prop: 'callbackId',
								disabled: true,
								span:8,
							},
						]
					},
					{
						//门店自提信息
						prop: 'group7',
						display: false,
						column: [
							{
								label: '配货单号',
								prop: 'distributionSn',
								disabled: true,
								span:8,
							},
							{
								label: '自提时间',
								prop: 'storeWillCallTime',
								disabled: true,
								span:8,
							},
							{
								label: '门店信息',
								prop: 'storeWillInfo',
								disabled: true,
								span:8,
							},
							{
								label: '门店地址',
								prop: 'storeWilladdress',
								disabled: true,
								span:8,
							},
							{
								label: '门店电话',
								prop: 'phone',
								disabled: true,
								span:8,
							},
							{
								label: '操作说明',
								prop: 'distributionDesc',
								disabled: true,
								span:8,
							}
						]
					},
					{
						//配货单信息
						prop: 'group9',
						column: [
							{
								prop: 'serviceSn',
								formslot: true,
								span: 24
							}
						]
					},
					{
						//操作历史
						prop: 'group8',
						column: [
							{
								prop: 'history',
								formslot: true,
								span: 24
							}
						]
					}
				]
			},
			//修改价格
			optionChangePrice: {
				emptyBtn: false,
				submitText: '提交',
				labelWidth: '150',
				column: [
					{
						label: '涨价或降价',
						prop: 'adjustmentPrice',
						row: true,
						span: 18,
						type: 'number',
						precision: 2,
						minRows: -99999,
						change: event => {
							if (event.value == undefined) {
								this.changePriceObj.adjustmentPrice = 0.0;
								//做加减操作
								let num = 1.0;
								num =
									Number(this.changePriceObj.totalPrice) +
									Number(this.changePriceObj.actualShipmentAmount) -
									Number(this.changePriceObj.couponAmountStore) -
									Number(this.changePriceObj.couponAmountPlatform) +
									Number(this.changePriceObj.adjustmentPrice) -
									Number(this.changePriceObj.fullCutAmount) -
									Number(this.changePriceObj.fullDiscountAmount) -
									Number(this.changePriceObj.integralTotalAmount);
								this.lastAmount = num.toFixed(2);
							} else if (this.changePriceObj.adjustmentPrice != event.value) {
								if (event.value < 0) {
									//降价
									//降价 > 运费 - 商品原价*件数 (此时的值都是负数)
									if (this.changePriceObj.actualShipmentAmount != this.actualShipmentAmount) {
										//先修改运费
										// if(event.value< (Number(this.changePriceObj.actualShipmentAmount) - Number(this.changePriceObj.totalPrice))){
										if (this.lastAmount < Number(this.changePriceObj.actualShipmentAmount)) {
											event.value = -Number(this.changePriceObj.totalPrice);
											// event.value=Number(this.changePriceObj.actualShipmentAmount) - Number(this.changePriceObj.totalPrice)
											this.changeMinrows(event.value);
											this.$message.error('不能再少了1！！！');
										}
									} else {
										//没修过运费时
										if (event.value < -Number(this.changePriceObj.totalPrice)) {
											event.value = -Number(this.changePriceObj.totalPrice);
											this.changeMinrows(event.value);
											this.$message.error('不能再少了！！！');
										}
									}
								}
								this.changePriceObj.adjustmentPrice = event.value;
								//做加减操作
								let num = 1.0;
								num =
									Number(this.changePriceObj.totalPrice) +
									Number(this.changePriceObj.actualShipmentAmount) -
									Number(this.changePriceObj.couponAmountStore) -
									Number(this.changePriceObj.couponAmountPlatform) +
									Number(this.changePriceObj.adjustmentPrice) -
									Number(this.changePriceObj.fullCutAmount) -
									Number(this.changePriceObj.fullDiscountAmount) -
									Number(this.changePriceObj.integralTotalAmount);
								//这里会出现精度丢失的问题，而且这个数字不会提交到后台，所以做四舍五入处理
								this.lastAmount = num.toFixed(2);
							}
							if (this.lastAmount < this.changePriceObj.actualShipmentAmount) {
								this.$message.error('实付款不能小于运费！！！');
							}
						},
						rules: [
							{
								required: true,
								message: '请输入涨价或降价',
								trigger: 'blur'
							}
						]
					},
					{
						label: '运费',
						prop: 'actualShipmentAmount',
						row: true,
						//type: 'input',
						span: 18,
						//dataType: 'number',
						type: 'number',
						precision: 2,
						mock: {
							type: 'number',
							max: 1,
							min: 2,
							precision: 2
						},
						minRows: 0,
						change: event => {
							if (event.value == undefined) {
								this.changePriceObj.actualShipmentAmount = 0.0;
								//做加减操作
								let num = 1.0;
								num =
									Number(this.changePriceObj.totalPrice) +
									Number(this.changePriceObj.actualShipmentAmount) -
									Number(this.changePriceObj.couponAmountStore) -
									Number(this.changePriceObj.couponAmountPlatform) +
									Number(this.changePriceObj.adjustmentPrice) -
									Number(this.changePriceObj.fullCutAmount) -
									Number(this.changePriceObj.fullDiscountAmount) -
									Number(this.changePriceObj.integralTotalAmount);
								this.lastAmount = num.toFixed(2);
							} else {
								if (event.value < this.changePriceObj.actualShipmentAmount) {
									//减少运费
									this.changePriceObj.actualShipmentAmount = event.value;
									// adjustmentPrice 涨价或降价 降价时 增加运费 降价最小值加1
									//actualShipmentAmount 运费
									if (this.changePriceObj.adjustmentPrice < 0) {
										//降价
										if (this.adjustmentPrice != this.changePriceObj.adjustmentPrice) {
											//先修改降价
											if (this.changePriceObj.adjustmentPrice < Number(this.changePriceObj.actualShipmentAmount) - Number(this.changePriceObj.totalPrice)) {
												this.changePriceObj.adjustmentPrice = -Number(this.changePriceObj.totalPrice);
											}
										} else {
											//先改运费
											if (this.changePriceObj.adjustmentPrice < Number(this.changePriceObj.actualShipmentAmount) - Number(this.changePriceObj.totalPrice)) {
												this.changePriceObj.adjustmentPrice = Number(this.changePriceObj.actualShipmentAmount) - Number(this.changePriceObj.totalPrice);
											}
										}
									}
								} else {
									this.changePriceObj.actualShipmentAmount = event.value;
								}

								//做加减操作
								let num = 1.0;
								num =
									Number(this.changePriceObj.totalPrice) +
									Number(this.changePriceObj.actualShipmentAmount) -
									Number(this.changePriceObj.couponAmountStore) -
									Number(this.changePriceObj.couponAmountPlatform) +
									Number(this.changePriceObj.adjustmentPrice) -
									Number(this.changePriceObj.fullCutAmount) -
									Number(this.changePriceObj.fullDiscountAmount) -
									Number(this.changePriceObj.integralTotalAmount);
								this.lastAmount = num.toFixed(2);
							}
							if (this.lastAmount < this.changePriceObj.actualShipmentAmount) {
								this.$message.error('实付款不能小于运费！！！');
							}
						},
						rules: [
							{
								required: true,
								message: '请输入邮费',
								trigger: 'blur'
							}
						]
					},
					{
						label: '收货地址',
						prop: 'address',
						row: true,
						type: 'input',
						readonly: true,
						span: 18
					},
					{
						label: '买家实付',
						prop: 'lastTotalAmount',
						row: true,
						formslot: true,
						readonly: true,
						span: 18
					},
					{
						label: '说明',
						prop: 'reason',
						row: true,
						formslot: true,
						readonly: true,
						span: 18
					}
				]
			},
			//退款审核
			optionRefund: {
				emptyBtn: false,
				submitText: '提交',
				labelWidth: '150',
				column: [
					{
						label: '申请说明',
						prop: 'oRefundApplyReason',
						row: true,
						type: 'textarea',
						readonly: true,
						span: 18
					},
					{
						label: '审核状态',
						prop: 'status',
						row: true,
						type: 'radio',
						dicData: VAILD,
						valueDefault: true,
						span: 18
					}
				]
			},
			//修改收货地址
			optionEdit: {
				emptyBtn: false,
				submitText: '提交',
				labelWidth: '150',
				column: [
					{
						label: '收货人',
						prop: 'trueName',
						row: true,
						type: 'input',
						span: 18,
						maxlength: 10,
						rules: [
							{
								required: true,
								message: '请输入收货人',
								trigger: 'blur'
							}
						]
					},
					{
						label: '收货人电话',
						prop: 'mobile',
						type: 'input',
						row: true,
						span: 18,
						rules: [
							{
								required: true,
								// message: '请输入收货人电话',
								trigger: 'blur',
								validator: testPhone
							}
						]
					},
					{
						label: '收货地址',
						prop: 'provinceAreaId',
						type: 'select',
						labelWidth: '150',
						span: 10,
						props: {
							label: 'area_name',
							value: 'id'
						},
						cascaderItem: ['cityAreaId', 'countyAreaId'],
						cascaderChange: true,
						dicUrl: `${baseUrl}?level=0`,
						rules: [
							{
								required: true,
								message: '请选择省份',
								trigger: 'blur'
							}
						]
					},
					{
						label: '城市',
						prop: 'cityAreaId',
						type: 'select',
						span: 6,
						labelWidth: '60',
						props: {
							label: 'area_name',
							value: 'id'
						},
						defaultIndex: 1,
						dicFlag: false,
						dicUrl: `${baseUrl}?parentId={{key}}&&level=1`,
						rules: [
							{
								required: true,
								message: '请选择城市',
								trigger: 'blur'
							}
						]
					},
					{
						label: '地区',
						prop: 'countyAreaId',
						type: 'select',
						span: 6,
						labelWidth: '60',
						row: true,
						props: {
							label: 'area_name',
							value: 'id'
						},
						defaultIndex: 1,
						dicFlag: false,
						dicUrl: `${baseUrl}?parentId={{key}}&&level=2`,
						rules: [
							{
								required: true,
								message: '请选择地区',
								trigger: 'blur'
							}
						]
					},
					{
						label: '详细地址',
						prop: 'areaInfo',
						type: 'textarea',
						span: 18,
						row: true,
						rules: [
							{
								required: true,
								message: '请输入详细地址',
								trigger: 'blur'
							}
						]
					}
				]
			},
			optionChange: {},
			dialogOrderGoodsVisible:false,
			orderFormGoodsResults:[],//订单下商品
			//宝贝详情
			option1: {
				border: true,
				header: false,
				menu: false,
				size: 'mini',
				menuAlign: 'center',
				// align: 'center',
				column: [
					{
						label: '商品名称',
						prop: 'goodsName'
					},
					{
						label: '宝贝图片',
						prop: 'goodsMainPhotoUrl',
						width: 80,
						slot: true
					},
					{
						label: '商品大类',
						prop: 'goodsClassName1',
						width: 80
					},
					{
						label: '商品子类',
						prop: 'goodsClassName2',
						width: 80
					},
					{
						label: '商品小类',
						prop: 'goodsClassName3',
						width: 100
					},
					{
						label: '是否退款退货/仅退款',
						prop: 'orRefund',
						width: 170
					},
					{
						label: '商品类型',
						width: 100,
						prop: 'choiceType',
						dicData: Dict.GOODS_CHOICE_TYPE
					},
					{
						label: '商品规格',
						prop: 'specInfo',
						width: 120
					},
					{
						label: '商品单价',
						width: 70,
						prop: 'mallPrice'
					},
					{
						label: '商品数量',
						width: 70,
						prop: 'count'
					},
					{
						label: '商品小计',
						width: 70,
						prop: 'node'
					},
					{
						label: '平台活动-团长分销拼团价格立减',
						prop: 'platformLeaderDistributionCut',
						width: 120
					},
					{
						label: '平台活动-余额抵扣',
						prop: 'platformBalanceDeduction',
						width: 120
					},
					{
						label: '平台活动-优惠券优惠',
						prop: 'mallCouponAmount',
						width: 120
					},
					{
						label: '平台活动汇总',
						prop: 'platformActivitySummary',
						width: 120
					},
					{
						label: '商家活动-秒杀立减',
						prop: 'storeSpikeCut',
						width: 120
					},
					{
						label: '商家活动-满额立减',
						prop: 'fullCutPrice',
						width: 120
					},
					{
						label: '商家活动-优惠券立减',
						prop: 'storeCouponAmount',
						width: 120
					},
					{
						label: '商家活动-团长分销拼团立减',
						prop: 'storeLeaderDistributionCut',
						width: 120
					},
					{
						label: '商家活动-普通拼团活动立减',
						prop: 'storeCommonGroup',
						width: 120
					},
					{
						label: '商家活动汇总',
						prop: 'storeActivitySummary',
						width: 120
					},
					{
						label: '商家活动-满赠 是否 ',
						prop: 'orGift',
						width: 120
					},
					{
						label: '商品约定结算价',
						width: 100,
						prop: 'purchasePrice'
					},
					{
						label: '商品提佣比例',
						width: 100,
						prop: 'commissionRate'
					},
					{
						label: '公司所得差额',
						prop: 'commissionValue',
						width: 100
					},
					{
						label: '退款金额',
						prop: 'refundPrice',
						width: 70
					}
					// {
					// 	label: "退款状态",
					// 	prop: "user1",
					// 	width:70,
					// },
				]
			},
			option: {
				size: 'mini',
				tip: true,
				border: true,
				height: 'auto',
				dialogType: 'dialog',
				rowKey: 'orderId',
				defaultExpandAll: false,
				align: 'center',
				menuWidth: 300,
				addBtn: false,
				editBtn: false,
				delBtn: false,
				selection: true,
				column: [
					{
						label: '订单编号',
						prop: 'orderId',
						width: 160,
						searchSpan:8,
						search: true
					},
					{
						label: '订单状态',
						prop: 'orderStatus',
						type: 'select',
						search: true,
						width: 100,
						searchSpan:8,
						disabled: true,
						dicData: orderStatusEnum
					},
					{
						label: '收货人姓名',
						prop: 'addressTrueName',
						width: 130,
						searchSpan:8,
						searchLabelWidth:90,
						search: true
					},
					{
						label: '联系方式',
						prop: 'addressMobile',
						width: 100,
						searchSpan:8,
						search: true
					},
					{
						label: '收货地址',
						prop: 'addressAreaInfo',
						width: 150
					},
					{
						label: '买家实付金额',
						prop: 'lastTotalAmount',
						width: 100
					},
					{
						label: '是否为业主',
						prop: 'user1',
						width: 120
					},
					{
						label: '买家备注',
						prop: 'buyerMsg',
						width: 120
					},
					{
						label: '快递费',
						prop: 'actualShipmentAmount',
						width: 80
					},
					{
						label: '配送方式',
						prop: 'expressType',
						type: 'select',
						dicData: Dict.expressTypeEnum,
						width: 80
					},
					{
						label: '订单总金额',
						searchLabelWidth: 100,
						prop: 'totalPrice',
						slot: true,
						width: 100
					},
					{
						label: '支付时间',
						prop: 'oPayTime',
						width: 135
					},
					{
						label: '下单时间',
						prop: 'addTime',
						width: 135
					},
					{
						label: '业务发生区域',
						prop: 'regionalOrganizationStr',
						width: 120
					},
					{
						label: '业务发生单元',
						prop: 'businessUnitOrganizationStr',
						width: 120
					},
					{
						label: '业务发生项目',
						prop: 'itemOrganizationStr',
						width: 120
					},
					{
						label: '店铺账号ID',
						prop: 'tripartiteStoreId',
						width: 90
					},
					{
						label: '店铺类型',
						prop: 'storeTypeName',
						width: 100
					},
					{
						label: '店铺名称',
						prop: 'storeName',
						width: 200
					},
					{
						label: '支付方式',
						prop: 'payWay',
						type: 'select',
						dicData: Dict.payWayEnum,
						width: 80
					},
				]
			},
			data: []
		};
	},
	computed: {
		...mapGetters(['permission', 'userInfo']),
		permissionList() {
			return {};
		}
	},
	watch: {
		'form1.expressType'() {
			if (this.form1.expressType == 0) {
				//自供货
				// this.optionDetail.group[5].column[1].display = false;
			}
		},
		'form1.invoiceType'() {
			if (this.form1.invoiceType == 0) {
				//个人发票
				this.optionDetail.group[4].column[6].display = true;
				this.optionDetail.group[4].column[7].display = false;
				this.optionDetail.group[4].column[8].display = true;
			} else if (this.form1.invoiceType == 2) {
				//不开发票
				this.optionDetail.group[4].column[6].display = false;
				this.optionDetail.group[4].column[7].display = false;
				this.optionDetail.group[4].column[8].display = false;
			} else if (this.form1.invoiceType == 1) {
				this.optionDetail.group[4].column[6].display = true;
				this.optionDetail.group[4].column[7].display = true;
				this.optionDetail.group[4].column[8].display = true;
			}
		}
	},
	created() {
		if (localStorage.getItem('orderState')) {
			let state = localStorage.getItem('orderState').toString();
			console.log(state);
			localStorage.removeItem('orderState');
			this.activeName = state;
			this.handleClick({ name: state });
		} else {
			let state = '-10';
			this.activeName = state;
			this.handleClick({ name: state });
		}
	},
	methods: {
		outExcel() {
			let token = getToken();
			let orderId = this.query.orderId === undefined ? '' : this.query.orderId;
			let orderStatus = this.query.orderStatus === undefined ? '' : this.query.orderStatus;
			let addTimeBegin = this.query.addTimeBegin === undefined ? '' : this.query.addTimeBegin;
			let addTimeEnd = this.query.addTimeEnd === undefined ? '' : this.query.addTimeEnd;
			window.location.href =
				'/order/sellerOrderForm/outExcel?token=' +
				token +
				'&orderId=' +
				orderId +
				'&orderStatus=' +
				orderStatus +
				'&addTimeBegin=' +
				addTimeBegin +
				'&addTimeEnd=' +
				addTimeEnd;
		},
		outLittleExcel() {
			if (this.idList.length > 0){
				let token = getToken();
				let storeName = this.query.storeName === undefined ? '' : this.query.storeName;
				let addressMobile = this.query.addressMobile === undefined ? '' : this.query.addressMobile;
				let orderId = this.query.orderId === undefined ? '' : this.query.orderId;
				let userName = this.query.userName === undefined ? '' : this.query.userName;
				let payWay = this.query.payWay === undefined ? '' : this.query.payWay;
				let orderStatus = this.query.orderStatus === undefined ? '' : this.query.orderStatus;
				let reconciliationStatus = this.query.reconciliationStatus === undefined ? '' : this.query.reconciliationStatus;
				let addTimeBegin = this.query.addTimeBegin === undefined ? '' : this.query.addTimeBegin;
				let addTimeEnd = this.query.addTimeEnd === undefined ? '' : this.query.addTimeEnd;
				let addressTrueName=this.query.addressTrueName===undefined?'':this.query.addressTrueName;
				let regionalOrganizationId=this.query.regionalOrganizationId===undefined?'':this.query.regionalOrganizationId;
				let businessUnitOrganizationId=this.query.businessUnitOrganizationId===undefined?'':this.query.businessUnitOrganizationId;
				let itemOrganizationId=this.query.itemOrganizationId===undefined?'':this.query.itemOrganizationId;
				let idList = this.idList;
				window.location.href =
						'/order/sellerOrderForm/outExcelOfGoods?token=' +
						token +
						'&storeName=' +
						storeName +
						'&addressMobile=' +
						addressMobile +
						'&orderId=' +
						orderId +
						'&userName=' +
						userName +
						'&payWay=' +
						payWay +
						'&reconciliationStatus=' +
						reconciliationStatus +
						'&orderStatus=' +
						orderStatus +
						'&addTimeBegin=' +
						addTimeBegin +
						'&addTimeEnd=' +
						addTimeEnd +
						'&idList=' +
						idList +
						'&addressTrueName=' + addressTrueName +
						'&regionalOrganizationId='+regionalOrganizationId+
						'&businessUnitOrganizationId='+businessUnitOrganizationId+
						'&itemOrganizationId='+itemOrganizationId;
				setTimeout(()=>{
					this.idList = [];
					this.onLoad(this.page, this.query);
				},500)
			}else {
				this.$message({
					type: "error",
					message: "至少选择一笔数据"
				});
			}
		},
		outOrderGoodsExcel() {
			let token = getToken();
			let orderId = this.query.orderId === undefined ? '' : this.query.orderId;
			let orderStatus = this.query.orderStatus === undefined ? '' : this.query.orderStatus;
			let addTimeBegin = this.query.addTimeBegin === undefined ? '' : this.query.addTimeBegin;
			let addTimeEnd = this.query.addTimeEnd === undefined ? '' : this.query.addTimeEnd;
			let addressTrueName=this.query.addressTrueName===undefined?'':this.query.addressTrueName;
			let regionalOrganizationId=this.query.regionalOrganizationId===undefined?'':this.query.regionalOrganizationId;
			let businessUnitOrganizationId=this.query.businessUnitOrganizationId===undefined?'':this.query.businessUnitOrganizationId;
			let itemOrganizationId=this.query.itemOrganizationId===undefined?'':this.query.itemOrganizationId;
			window.location.href =
					'/order/sellerOrderForm/outExcelOfGoods?token=' +
					token +
					'&orderId=' +
					orderId +
					'&orderStatus=' +
					orderStatus +
					'&addTimeBegin=' +
					addTimeBegin +
					'&addTimeEnd=' +
					addTimeEnd+
					'&addressTrueName='+addressTrueName+
					'&regionalOrganizationId='+regionalOrganizationId+
					'&businessUnitOrganizationId='+businessUnitOrganizationId+
					'&itemOrganizationId='+itemOrganizationId;
		},
		changeMinrows(num) {
			this.optionChangePrice.column[0].minRows = num;
		},
		seeDetails(id,storeWillCallId) {
			//查看详情
			getDetail(id).then(res => {
				if (res.data.code != 200) {
					return;
				}
				var data = res.data.data;
				this.form1.regionalOrganizationStr = data.regionalOrganizationStr;
				this.form1.businessUnitOrganizationStr = data.businessUnitOrganizationStr;
				this.form1.itemOrganizationStr = data.itemOrganizationStr;
				this.form1.orderId = data.orderForm.orderId;
				this.form1.oPayTime = data.orderForm.addTime;
				this.form1.payWay = data.orderForm.payWay;
				this.form1.pfCode = data.orderForm.pfCode || ''
                this.form1.payFormId = data.orderForm.payFormId || ''
				this.form1.storeName = data.orderForm.storeName;
				this.form1.storeTypeName = data.store.storeTypeName;
				this.form1.tripartiteStoreId = data.store.tripartiteStoreId;
				this.form1.sellerPhoneNumber = data.orderForm.sellerPhoneNumber;
				this.form1.sellerAddress = data.orderForm.sellerAddress;
				data.orderDistributionList.forEach(item=>{
					if(item.orderFormGoodsResultList!=""){
						item.orderFormGoodsResultList.forEach(good=>{
							good.purchasePrice = good.goodsSkuData.purchasePrice
							good.commissionRate = good.goodsSkuData.commissionRate
							good.commissionValue = good.goodsSkuData.commissionValue
						})
					}
				})
				if(this.form1.payFormId.trim().length!=0) {
					getCallbackIdByPayFormId({payFormId:this.form1.payFormId}).then(request=>{
						if(request.data.code==200) {
							this.form1.callbackId = request.data.data.callbackId
							console.log('callbackId',this.form1.callbackId)
						}
					})
				}
				this.form1.orderDistributionList = data.orderDistributionList;
				this.form1.orderAfterSaleServiceResultList = data.orderAfterSaleServiceResultList;
				this.form1.goodsDetail = data.orderGoodsList;
				this.form1.trueName = data.orderAddress.trueName;
				this.form1.address = data.orderAddress.provinceAreaName + data.orderAddress.cityAreaName + data.orderAddress.countyAreaName;
				this.form1.areaInfo = data.orderAddress.areaInfo;
				this.form1.mobile = data.orderAddress.mobile;
				this.form1.buyerMsg = data.orderFormInfoResultList[0].buyerMsg;
				this.form1.invoiceType = data.orderFormInfoResultList[0].invoiceType; //发票类型
				this.form1.invoiceTitle = data.orderFormInfoResultList[0].invoiceTitle; //发票抬头
				this.form1.invoiceTaxNum = data.orderFormInfoResultList[0].invoiceTaxNum; //纳税人识别号
				this.form1.invoiceEmail = data.orderFormInfoResultList[0].invoiceEmail; //接收发票邮箱
				this.form1.invoiceUploadResultMsg = data.orderFormInfoResultList[0].invoiceUploadResultMsg; //接收发票邮箱
				this.form1.invoiceUrl = data.orderFormInfoResultList[0].invoiceUrl; //链接
				this.form1.expressType = data.orderFormInfoResultList[0].expressType; //运输类型
				this.form1.expressCompanyName = data.orderFormInfoResultList[0].expressCompanyName; //物流公司名
				this.form1.shipCode = data.orderFormInfoResultList[0].shipCode; //快递单号
				this.form1.totalPrice = data.orderForm.totalPrice; //订单总价
				this.form1.lastAmount = data.orderFormAmount[0].lastAmount; //总付款
				this.form1.actualShipmentAmount = data.orderFormAmount[0].actualShipmentAmount; //运费
				this.form1.couponAmountPlatform = data.orderFormAmount[0].couponAmountPlatform; //平台优惠
				this.form1.fullCutAmount = data.orderFormAmount[0].fullCutAmount; //满减优惠
				this.form1.fullDiscountAmount = data.orderFormAmount[0].fullDiscountAmount; //满折优惠
				this.form1.couponAmountStore = data.orderFormAmount[0].couponAmountStore; //店铺优惠
				this.form1.isUseIntegral = data.orderFormAmount[0].isUseIntegral; //是否使用积分抵扣
				this.form1.integralTotalAmount = data.orderFormAmount[0].integralTotalAmount; //积分抵扣金额
				this.form1.historyLog = data.logList; //操作历史
				this.form1.platformReward = data.platformReward; //平台奖励团长金额
				this.form1.storeReward = data.storeReward; //店铺奖励团长金额
				if(this.form1.invoiceUrl==''&&this.form1.invoiceUploadResultMsg!=''){
					this.optionDetail.group[4].column[9].display = true
				}else{
					this.optionDetail.group[4].column[9].display = false
				}
				getStoreWillCallId(storeWillCallId).then(res1=>{
					this.form1.phone = res1.data.data.phone
					this.form1.storeWillInfo = res1.data.data.storeName
					this.form1.storeWilladdress = res1.data.data.address
				})
				if(this.form1.expressType==0){//自提
					this.optionDetail.group[4].display=false
					this.optionDetail.group[6].display=true
				}else{
					this.optionDetail.group[4].display=true
					this.optionDetail.group[6].display=false
				}
				if(data.orderDistributionList.length>0){
					this.form1.distributionSn = data.orderDistributionList[0].distributionSn
					this.form1.distributionDesc = data.orderDistributionList[0].distributionDesc || ' '
					this.form1.storeWillCallTime = data.orderDistributionList[0].storeWillCallBeginTime.split(" ",1) +" -- "+ data.orderDistributionList[0].storeWillCallEndTime.split(" ",1) || ' '
				}
			});
			console.log(this.form1);
			this.dialogDeatilVisible = true;
		},
		// 修改金额提交
		submitChangePrice(from, down) {
			//    if(this.changePriceObj.adjustmentPrice < -this.changePriceObj.totalPrice){
			// 	this.$message.error("降价后价格小于零！请重新填写涨价或降价");
			//  down();
			// 	return;
			// }输入降价或涨价做了限制 这个用不到 先注释 以防以后出问题
			//限制运费的金额
			if (this.changePriceObj.actualShipmentAmount >= 100000000) {
				this.$message.error('运费金额超出最大限制');
				down();
				return;
			}
			if (this.lastAmount < this.changePriceObj.actualShipmentAmount) {
				this.$message.error('实付款不能小于运费！！！');
				down();
				return;
			}
			let data = {
				id: this.changePriceObj.id,
				orderFormId: this.changePriceObj.orderFormId,
				adjustmentPrice: this.changePriceObj.adjustmentPrice,
				actualShipmentAmount: this.changePriceObj.actualShipmentAmount
			};
			updatePrice(data).then(res => {
				down();
				if (res.data.code == 200) {
					this.$message.success('修改成功!');
				} else {
					this.$message.error(res.data.message);
				}
				this.changePriceObj = {};
				this.actualShipmentAmount = 0.0;
				this.adjustmentPrice = 0.0;
				this.lastAmount = 0.0;
				this.onLoad(this.page, this.query);
				this.dialogFormVisible = false;
			});
		},
		submit(form, down) {
			if (this.obj.oRefundApplyReason) {
				//退款审核
				console.log(this.orderId);
				console.log(this.obj.status);
				refundSuccess(this.orderId, this.obj.status).then(res => {
					down();
					if (res.data.code == 200) {
						this.onLoad(this.page, this.query);
						this.$message.success(res.data.message);
					} else {
						this.$message.error(res.data.message);
					}
					this.dialogFormVisible = false;
				});
			} else if (this.obj.provinceAreaName) {
				//修改地址
				this.obj.provinceAreaName = this.obj.$provinceAreaId;
				this.obj.cityAreaName = this.obj.$cityAreaId;
				this.obj.countyAreaName = this.obj.$countyAreaId;
				if (this.obj.areaInfo.length > 30) {
					this.$message({
						type: 'error',
						message: '不能超过30个字'
					});
					down();
					return;
				}

				modifyOrderAddress(this.obj).then(res => {
					down();
					if (res.data.code == 200) {
						this.$message.success('修改成功!');
					} else {
						this.$message.error(res.data.message);
					}
					this.onLoad(this.page, this.query);
					this.dialogFormVisible = false;
				});
			} else {
				//修改价格
				down();
			}
		},
		//确定取消订单
		cancelOrderForm() {
			console.log(this.cancelReason);
			let reason = '';
			if (this.cancelReason == 3) {
				reason = '买家要求取消';
			} else if (this.cancelReason == 6) {
				reason = '商品缺货';
			} else if (this.cancelReason == 9) {
				reason = '其他原因';
			}
			if (this.cancelReason) {
				cancelOrder(this.orderId, reason).then(res => {
					if (res.data.code == 200) {
						this.$message.success('订单已取消!');
					} else {
						this.$message.error(res.data.message);
					}
					this.onLoad(this.page, this.query);
					this.dialogCancelForm = false;
				});
			} else {
				this.$message({
					type: 'error',
					message: '请选择取消原因!'
				});
			}
		},
		cellStyle({ columnIndex }) {
			if (columnIndex == 1) {
				return {
					textAlign: 'left'
				};
			} else {
				return {
					textAlign: 'center'
				};
			}
		},
		cellStyle1({row,columnIndex}){
			if(columnIndex==18){
				if(row.orderStatus==45){
					return {
						color:'red',
					}
				}
			}
		},
		//查看订单下商品
		viewOrderGoods(id){
			let obj = {
				ofId: id
			};
			getOrderFormGoods(obj).then(res => {
				if(res.data.code==200  ){
					if(res.data.data.length>0){
						res.data.data.forEach(item => {
							item.purchasePrice = item.goodsSkuData.purchasePrice;
							item.commissionRate = item.goodsSkuData.commissionRate;
							item.commissionValue = item.goodsSkuData.commissionValue;
						});
					}
					this.orderFormGoodsResults =res.data.data
					this.dialogOrderGoodsVisible = true
				}else{
					this.$message.warning(res.data.message)
				}
			});
		},
		closeOrderGoods(){
			this.orderFormGoodsResults = []
			this.dialogOrderGoodsVisible = false
		},
		//选择项目
		changeAreaForRongChuang(parentId, lev) {
		    //省级选择框
		    if (lev == 3) {//区域
		        getOrganizationListByLevel(parentId, lev).then(res => {
		            if (lev == 3) {
		                this.rcityId = "";
		                this.projectId = "";
		                this.rcitys = res.data.data;
		            }
		        })
		    }
		    if (lev == 4) {//城市
		        getOrganizationListByLevel(parentId, lev).then(res => {
		            if (lev == 4) {
		                this.projects = res.data.data;
		            }
		        })
		    }
		},
		getBeginTime() {
			if (this.addTimeEnd) {
				if (this.addTimeBegin > this.addTimeEnd) {
					this.$message({
						type: 'error',
						message: '开始时间不能大于结束时间'
					});
					this.addTimeBegin = '';
				}
			}
		},
		getEndTime() {
			if (this.addTimeBegin) {
				if (this.addTimeBegin > this.addTimeEnd) {
					this.$message({
						type: 'error',
						message: '结束时间不能小于开始时间'
					});
					this.addTimeEnd = '';
				}
			}
		},
		rowStyle() {
			return {
				backgroundColor: '#f3f3f3',
				color: '#333333'
			};
		},
		onload(val) {
			console.log(val)
		},
		closeDialog() {
			this.dialogVisible = false;
		},
		closeDetailDialog() {
			this.form1={};
			this.dialogDeatilVisible = false;
		},
		//退款
		refundGoods(orderId) {
			this.$confirm('是否将款项全部退还买家?', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				refundOrder(orderId).then(res => {
					if (res.data.code == 200) {
						this.$message.success(res.data.message);
					} else {
						this.$message.error(res.data.message);
					}
					this.onLoad(this.page, this.query);
				});
			});

			console.log('退款');
		},
		//审核
		// async checkGoods(orderId,row) {
		// 	console.log(row)
		// 	await approveOrder(orderId).then((res) => {
		// 		if (res.data.code != 200) {
		// 			return;
		// 		}
		// 		this.$message({
		// 			type: "success",
		// 			message: "审核成功!"
		// 		});
		// 	});
		// 	await this.onLoad(this.page, this.query)
		// 	await getOrderFormGoods({ofId:row.id}).then((res) => {
		// 		row.orderFormGoodsResults = res.data.data;
		// 	});
		// },

		async checkGoods(orderId, row) {
			if (this.Fntimer) {
				clearTimeout(this.Fntimer);
			}
			this.Fntimer = setTimeout(() => {
				approveOrder(orderId).then(res => {
					if (res.data.code == 200) {
						this.$message.success('审核成功!');
					} else {
						this.$message.success(res.data.message);
					}
				});
				this.onLoad(this.page, this.query);
				getOrderFormGoods({ ofId: row.id }).then(res => {
					row.orderFormGoodsResults = res.data.data;
				});
			}, 2000);
		},
		//联系用户
		callUser(userId) {
			this.$EventBus.$emit('chat', { userId: userId });
		},
		//修改地址
		editAddress(id) {
			this.optionChange = this.optionEdit;
			getOrderAddress(id).then(res => {
				if (res.data.code != 200) {
					return;
				}
				this.obj = res.data.data;
			});
			this.orderId = id;
			this.title = '修改地址';
			this.dialogType = 1;
			this.dialogFormVisible = true;
			//   获取地址信息
		},
		//取消订单
		cancelOrderDetail(id, orderIdSn) {
			this.title = '取消订单';
			this.dialogType = 0;
			this.orderId = id;
			this.orderIdSn = orderIdSn;
			this.dialogCancelForm = true;
			console.log('取消订单');
		},
		//退款审核
		refundGoodsCheck(id, reason) {
			this.optionChange = this.optionRefund;
			this.obj.oRefundApplyReason = reason;
			this.obj.status = 'false'; //默认不通过
			this.orderId = id;
			this.title = '退款审核';
			this.dialogType = 1;
			this.dialogFormVisible = true;
			console.log('退款审核');
		},
		//修改价格
		changeOrderPrice(row) {
			this.changePriceObj = {};
			getOrderAddress(row.id).then(res => {
				if (res.data.code == 200) {
					let data = res.data.data;
					let address = data.provinceAreaName + ' ' + data.cityAreaName + ' ' + data.countyAreaName + ' ' + data.areaInfo;
					this.changePriceObj.address = address;
					// this.changePriceObj.address = data.areaInfo
				}
			});
			getOrderAmount(row.id).then(res => {
				if (res.data.code == 200) {
					let data = res.data.data;
					data.totalPrice = Math.round((parseFloat(data.totalPrice) - parseFloat(data.actualShipmentAmount)) * 100) / 100; //保留2位小数。
					this.changePriceObj = data;
					console.log(this.changePriceObj);
					this.actualShipmentAmount = data.actualShipmentAmount;
					this.adjustmentPrice = data.adjustmentPrice;
					this.lastAmount = res.data.data.lastAmount;
				}
			});
			this.orderId = row.id;
			this.changePriceObj.lastTotalAmount = row.lastTotalAmount.toFixed(2);
			this.title = '修改价格';
			this.dialogType = 2;
			this.dialogFormVisible = true;
		},
		//tabs切换
		handleClick(tab) {
			this.activeName = tab.name;
			if (tab.name == '-10') {
				tab.name = '';
				this.option.column[17].search = true;
			} else {
				this.option.column[17].search = false;
			}
			this.query.orderStatus = tab.name;
			this.page.currentPage = 1;
			this.onLoad(this.page, this.query);
			this.$refs.crud1.searchReset();
		},
		// 选中状态变化时
		selectionChange(list) {
			this.allMoney= 0;
			let tempAllMoney = 0;
			list.forEach(item => {
				tempAllMoney+=item.lastTotalAmount
			});
			tempAllMoney = Number(tempAllMoney);
			this.allMoney =Math.round(tempAllMoney * 100) / 100
			let idList = []
			if (list.length > 0) {
				for (let item of list) {
					idList.push(item.id)
				}
				console.log(idList)
				this.idList = idList
			} else {
				this.idList = [];
			}
		},
		searchReset() {
			this.query = {};
			if (this.activeName != '-10') {
				this.query.orderStatus = Number(this.activeName);
			}
			this.addTimeBegin = '';
			this.addTimeEnd = '';
			this.areaId = ''
			this.cityId = ''
			this.rareaId = ''
			this.rcityId = ''
			this.projectId = ''
			this.onLoad(this.page, this.query);
		},
		searchChange(params, done) {
			this.page.currentPage = 1;
			params.addTimeBegin = this.addTimeBegin;
			params.addTimeEnd = this.addTimeEnd;
			params.regionalOrganizationId = this.rareaId||''
			params.businessUnitOrganizationId = this.rcityId||''
			params.itemOrganizationId = this.projectId||''
			if (this.activeName != '-10') {
				params.orderStatus = Number(this.activeName);
			}
			this.query = params;
			this.onLoad(this.page, params, done);
		},
		currentChange(currentPage) {
			this.page.currentPage = currentPage;
		},
		sizeChange(pageSize) {
			this.page.pageSize = pageSize;
		},
		refreshChange() {
			this.onLoad(this.page);
		},
		onLoad(page, params = {}, done) {
			//重首页跳转过来的时候需要定位到对应的tab页
			this.loading = true;
			if (this.query.orderStatus) {
				this.query.orderStatus = Number(this.query.orderStatus);
			}

			getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
				if (done) {
					done();
				}
				if (res.data.code == 200) {
					this.loading = false;
					const data = res.data;
					this.page.total = data.count;
					this.data = data.data;
				} else {
					this.$message({
						type: 'error',
						message: res.data.data
					});
				}
			});
			getOrganizationListByLevel(2, 2).then(res => {
			    this.rareas = res.data.data;
			})
		},
		goAfterSaleServiceDetail(id) {
			this.$router.push({
				path: '/base/transaction/seller/orderAfterSaleService'
			});
			localStorage.setItem('afterSaleServiceDetailId', id);
		}
	}
};
</script>

<style scoped lang="scss">
	.drawerHeader {
		font-size: 17px;
		padding: 30px 20px;
	}
.el-col {
	float: none;
	display: inline-block;
	width: auto;
}
.el-table__expanded-cell {
	padding: 0 !important;
}

el-button {
	margin: 0.1rem;
}

.reason {
	color: #a8a8a8;
}

.distribution el-form-item__content {
	margin-left: 0;
}
.loading_icon {
	width: 30px;
	margin: auto;
}
.btnRow {
	position: relative;
	bottom: 51px;
	left: 10px;
}
.allMoney{
	margin-left: 5px;
}
</style>
